<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Select 点击测试</title>
    <style>
        body {
            font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
            margin: 0;
            padding: 20px;
            background: #f5f5f5;
        }
        
        .container {
            max-width: 600px;
            margin: 0 auto;
            padding: 30px;
            background: white;
            border-radius: 12px;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
        }
        
        .select-wrapper {
            position: relative;
            display: inline-block;
            margin: 20px 0;
        }
        
        .select-header {
            padding: 10px 16px;
            border: 2px solid #ddd;
            border-radius: 8px;
            background: white;
            cursor: pointer;
            min-width: 200px;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        
        .select-header:hover {
            border-color: #FF9ACD;
        }
        
        .select-dropdown {
            position: absolute;
            top: 100%;
            left: 0;
            right: 0;
            background: white;
            border: 1px solid #ddd;
            border-radius: 8px;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
            z-index: 9999;
            margin-top: 5px;
            display: none;
        }
        
        .select-dropdown.open {
            display: block;
        }
        
        .select-option {
            padding: 10px 16px;
            cursor: pointer;
            transition: background 0.2s ease;
            pointer-events: auto;
            position: relative;
        }
        
        .select-option:hover {
            background: #f0f0f0;
        }
        
        .select-option.selected {
            background: #FFE4E1;
            font-weight: 600;
        }
        
        .arrow {
            width: 0;
            height: 0;
            border-left: 5px solid transparent;
            border-right: 5px solid transparent;
            border-top: 6px solid #666;
            transition: transform 0.3s ease;
        }
        
        .arrow.up {
            transform: rotate(180deg);
        }
        
        .test-info {
            background: #f8f9fa;
            padding: 15px;
            border-radius: 8px;
            margin: 20px 0;
            border-left: 4px solid #007bff;
        }
        
        .log {
            background: #f8f9fa;
            padding: 10px;
            border-radius: 4px;
            font-family: monospace;
            font-size: 12px;
            margin: 10px 0;
            max-height: 200px;
            overflow-y: auto;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>Select 组件点击测试</h1>
        
        <div class="test-info">
            <h3>测试说明</h3>
            <p>这个测试页面用于验证 Select 组件的点击事件是否正常工作。</p>
            <p>请尝试点击下拉菜单中的每个选项，观察控制台日志和页面反馈。</p>
        </div>
        
        <div class="select-wrapper">
            <div class="select-header" onclick="toggleDropdown()">
                <span id="selected-value">请选择主题</span>
                <span class="arrow" id="arrow"></span>
            </div>
            <div class="select-dropdown" id="dropdown">
                <div class="select-option" onclick="selectOption('pink')">🌸 梦幻粉色</div>
                <div class="select-option" onclick="selectOption('blue')">💎 梦幻蓝色</div>
                <div class="select-option" onclick="selectOption('purple')">💜 梦幻紫色</div>
            </div>
        </div>
        
        <div class="test-info">
            <h3>当前选择</h3>
            <p>选中的值：<strong id="current-selection">无</strong></p>
            <p>点击次数：<strong id="click-count">0</strong></p>
        </div>
        
        <div class="test-info">
            <h3>点击日志</h3>
            <div class="log" id="log"></div>
            <button onclick="clearLog()" style="margin-top: 10px; padding: 5px 10px; background: #dc3545; color: white; border: none; border-radius: 4px; cursor: pointer;">清空日志</button>
        </div>
    </div>

    <script>
        let isOpen = false;
        let currentSelection = null;
        let clickCount = 0;
        
        function log(message) {
            const logElement = document.getElementById('log');
            const timestamp = new Date().toLocaleTimeString();
            logElement.innerHTML += `[${timestamp}] ${message}<br>`;
            logElement.scrollTop = logElement.scrollHeight;
            console.log(message);
        }
        
        function toggleDropdown() {
            const dropdown = document.getElementById('dropdown');
            const arrow = document.getElementById('arrow');
            
            isOpen = !isOpen;
            
            if (isOpen) {
                dropdown.classList.add('open');
                arrow.classList.add('up');
                log('下拉菜单已打开');
            } else {
                dropdown.classList.remove('open');
                arrow.classList.remove('up');
                log('下拉菜单已关闭');
            }
        }
        
        function selectOption(value) {
            log(`选项被点击: ${value}`);
            
            // 更新选中状态
            currentSelection = value;
            clickCount++;
            
            // 更新UI
            const selectedValueElement = document.getElementById('selected-value');
            const currentSelectionElement = document.getElementById('current-selection');
            const clickCountElement = document.getElementById('click-count');
            
            const labels = {
                'pink': '🌸 梦幻粉色',
                'blue': '💎 梦幻蓝色',
                'purple': '💜 梦幻紫色'
            };
            
            selectedValueElement.textContent = labels[value];
            currentSelectionElement.textContent = labels[value];
            clickCountElement.textContent = clickCount;
            
            // 更新选项样式
            const options = document.querySelectorAll('.select-option');
            options.forEach(option => {
                option.classList.remove('selected');
                if (option.onclick.toString().includes(value)) {
                    option.classList.add('selected');
                }
            });
            
            // 关闭下拉菜单
            isOpen = false;
            document.getElementById('dropdown').classList.remove('open');
            document.getElementById('arrow').classList.remove('up');
            
            log(`已选择: ${labels[value]}`);
        }
        
        function clearLog() {
            document.getElementById('log').innerHTML = '';
            log('日志已清空');
        }
        
        // 点击外部关闭下拉菜单
        document.addEventListener('click', function(event) {
            const wrapper = document.querySelector('.select-wrapper');
            if (!wrapper.contains(event.target) && isOpen) {
                toggleDropdown();
            }
        });
        
        // 初始化
        log('测试页面已加载');
    </script>
</body>
</html>